home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / exec / allocvec.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-12  |  1.8 KB  |  87 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: allocvec.c,v 1.4 1996/08/13 13:55:58 digulla Exp $
  4.     $Log: allocvec.c,v $
  5.     Revision 1.4  1996/08/13 13:55:58  digulla
  6.     Replaced __AROS_LA by __AROS_LHA
  7.     Replaced some __AROS_LH*I by __AROS_LH*
  8.     Sorted and added includes
  9.  
  10.     Revision 1.3  1996/08/01 17:41:05  digulla
  11.     Added standard header for all files
  12.  
  13.     Desc:
  14.     Lang:
  15. */
  16. #include "exec_intern.h"
  17. #include <aros/libcall.h>
  18. #include "machine.h"
  19. #include "memory.h"
  20.  
  21. /*****************************************************************************
  22.  
  23.     NAME */
  24.     #include <clib/exec_protos.h>
  25.  
  26.     __AROS_LH2(APTR, AllocVec,
  27.  
  28. /*  SYNOPSIS */
  29.     __AROS_LHA(ULONG, byteSize,     D0),
  30.     __AROS_LHA(ULONG, requirements, D1),
  31.  
  32. /*  LOCATION */
  33.     struct ExecBase *, SysBase, 114, Exec)
  34.  
  35. /*  FUNCTION
  36.     Allocate some memory from the sytem memory pool with the given
  37.     requirements and without the need to memorize the actual size
  38.     of the block.
  39.  
  40.     INPUTS
  41.     byteSize     - Number of bytes you want to get
  42.     requirements - Type of memory
  43.  
  44.     RESULT
  45.     A pointer to the number of bytes you wanted or NULL if the memory
  46.     couldn't be allocated
  47.  
  48.     NOTES
  49.  
  50.     EXAMPLE
  51.  
  52.     BUGS
  53.  
  54.     SEE ALSO
  55.     FreeVec()
  56.  
  57.     INTERNALS
  58.  
  59.     HISTORY
  60.     8-10-95    created by m. fleischer
  61.        16-10-95    increased portability
  62.  
  63. ******************************************************************************/
  64. {
  65.     __AROS_FUNC_INIT
  66.  
  67.     UBYTE *ret;
  68.  
  69.     /* Add room for stored size. */
  70.     byteSize+=ALLOCVEC_TOTAL;
  71.  
  72.     /* Get the memory. */
  73.     ret=(UBYTE *)AllocMem(byteSize,requirements);
  74.  
  75.     /* If there's not enough memory left return immediately. */
  76.     if(ret==NULL)
  77.     return NULL;
  78.  
  79.     /* Store size */
  80.     *(ULONG *)ret=byteSize;
  81.  
  82.     /* return free space */
  83.     return ret+ALLOCVEC_TOTAL;
  84.     __AROS_FUNC_EXIT
  85. } /* AllocVec */
  86.  
  87.